<template>
  <div class="my">
    <header class="top">
      <div class="oilnum">{{ ele.oilName }}</div>
      <div class="stationname">{{ ele.stationName }}</div>
      <div class="paytime">{{ ele.payDate }}</div>
      <section class="others">
        <div class="amount">
          <span>油品金额</span>
          <span>{{ ele.oilPirce }}元/L x {{ ele.orderLiters }}L</span>
        </div>
        <div class="carnum">
          <span>车牌号</span>
          <span>{{ !!ele.truckNumber ? ele.truckNumber : "暂未设置" }}</span>
        </div>
      </section>
      <div class="full">
        <span>应付金额</span>
        <span>{{ ele.receivableAmt }}元</span>
      </div>
    </header>
    <section class="center">
      <div class="amt">
        <span>实付金额</span>
        <span>{{ ele.amt }}元 <span class="arrows"> >> </span></span>
      </div>
      <div class="amt">
        <span>赠送金额</span>
        <span>{{ ele.presentAmt }}元 <span class="arrows"> >> </span></span>
      </div>
      <div class="invoice">
        <span>
          可开票金额
          <nuxt-link
            :to="{
              path: `/invoice`,
              query: {
                orderNo: ele.orderNo,
                maxAmt: invoiceInfo.invoiceBalance
              }
            }"
            tag="button"
          >
            去开票
          </nuxt-link>
          <!-- <van-popover v-model="showPopover" trigger="click" placement="right">
              <div>
                <div>听说你想开发票</div>
                <div>就是不给你开</div>
                <div>别急，我开玩笑</div>
              </div>
              <template #reference>
                <span class="icon"></span>
              </template>
            </van-popover> -->
        </span>
        <span>{{ ele.amt }}元</span>
      </div>
    </section>
    <footer class="bottom">
      <div class="ordernum">
        <span>订单编号</span>
        <span>{{ ele.orderNo }}</span>
      </div>
    </footer>
  </div>
</template>

<script>
import { mapState, mapGetters, mapActions } from "vuex";
import Vue from "vue";
import { Popover } from "vant";

Vue.use(Popover);
export default {
  head() {
    return {
      title: "订单详情"
    };
  },
  data() {
    return {
      showPopover: false,
      ele: {}
    };
  },
  components: {},
  computed: {
    ...mapGetters({
      userInfo: "authen/userInfo"
    }),
    ...mapState({
      // pointInfo: (state) => state.point.pointInfo,
    })
  },
  async created() {
    // if (!this.$route.params.id) {
    //   alert("此页不支持直接访问~");
    // }
    // const amountData = await this.$axios.$get("/selectOrderInfoByOrdNo", {
    //   params: {
    //     orderNo: this.$route.params.id
    //   }
    // });

    const amountData = {
      data: {
        amt: 6,
        appType: "1",
        cardType: "2",
        consumer: "LayX",
        createdDate: "2023-08-08 10:19:57",
        customerPhone: "13713504691",
        discountAmt: 0,
        dzkAmt: 0,
        enterpriseId: 173,
        integral: "0",
        merchantsNumber: "TI1691461222546",
        mobilePhone: "137****4691",
        oilGun: "6",
        oilId: 16,
        oilName: "0#",
        oilPersonnel: "--",
        oilPirce: "1.86",
        orderId: 772781,
        orderLiters: "3.2258",
        orderNo: "1691461197085909688",
        orderOriginType: "4",
        orderType: "柴油",
        payDate: "2023-08-08 10:20:31",
        payType: "wx",
        payTypeName: "微信",
        payWayId: 345,
        receivableAmt: 6,
        receivedAmt: 6,
        stationId: 233,
        stationName: "多站支付测试",
        status: "1",
        statusName: "已支付",
        transactionId: "TP1691461223762",
        unitCode: "1"
      },
      message: "成功",
      retCode: 0
    };

    if (amountData.retCode !== 0) {
      throw new Error(amountData.message);
    }
    this.ele = amountData.data;
  },
  mounted() {
    // this.getPointInfo();
  },
  methods: {
    ...mapActions({
      // getPointInfo: "point/getPointInfo",
    }),
    onSelect(action) {
      // Toast(action.text);
    }
  }
};
</script>

<style lang="scss">
.my {
  padding: 0.4rem;
  padding-bottom: 0;
  width: 100vw;
  min-height: 100vh;
  box-sizing: border-box;
  background-color: #f8f8f8;
  .top {
    background-color: #ffffff;
    overflow: hidden;
    padding: 0.2rem 0.25rem;
    display: flex;
    flex-direction: column;
    text-align: center;
    > div {
      height: 0.45rem;
      line-height: 0.45rem;
      font-size: 0.26rem;
    }
    .oilnum {
      height: 0.8rem;
      line-height: 0.8rem;
      font-size: 0.5rem;
      font-weight: bolder;
    }
    .stationname {
    }
    .paytime {
      font-size: 0.25rem;
    }
    .others {
      margin: 0 auto;
      margin-top: 0.5rem;
      width: 100%;
      background-color: #f8f8f8;
      display: flex;
      flex-direction: column;
      border-radius: 0.15rem;
      padding: 0.3rem 0.3rem;
      box-sizing: border-box;

      > div {
        height: 0.6rem;
        line-height: 0.6rem;
        display: flex;
        justify-content: space-between;
        span:nth-child(2) {
          color: #3c3c3c;
        }
      }
    }
    .full {
      display: flex;
      justify-content: space-between;
      font-size: 0.26rem;
      margin-top: 0.5rem;
      margin-bottom: 0.6rem;
      color: #0c0c0c;
      //font-weight:bold;
    }
  }
  .center {
    //background-color:#f8f8f8;
    > div {
      display: flex;
      justify-content: space-between;
      height: 0.9rem;
      line-height: 0.9rem;
      border-radius: 0 0 0.15rem 0.15rem;
      box-sizing: border-box;
      padding: 0 0.2rem;
      font-size: 0.26rcem;
    }
    .amt {
      background-color: #e8e8e8;
      .arrows {
        color: #737373;
      }
    }
    .invoice {
      .icon {
        display: inline-block;
        width: 0.26rem;
        height: 0.26rem;
        border-radius: 0.13rem;
        //background-color: #377ec4;
        margin-left: 0.2rem;
        margin-bottom: -2px;
        background: url("../static/common/qm.svg") no-repeat 0 0;
        background-size: 100% 100%;
      }
      button {
        width: 1.3rem;
        height: 0.6rem;
        line-height: 0.6rem;
        padding: 0;
        font-size: 0.26rem;
        color: blue;
        background-color: transparent;
        outline: none;
        border: none;
        box-shadow: 0px 1px 1px 0px skyblue;
      }
    }
  }
  .bottom {
    width: 100%;
    margin-top: 0.4rem;
    font-size: 0.26rem;
    > .ordernum {
      display: flex;
      justify-content: space-between;
      line-height: 1rem;
      height: 1rem;
      border-radius: 0.15rem;
      background: #ffffff;
      box-sizing: border-box;
      padding: 0 0.2rem;
      box-shadow: 0 1px 2px 2px rgba(201, 207, 207, 0.1);
    }
  }
}
</style>
